package com.czk.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * 整合nacos
 * 注册其余工程到nacos
 *
 * @Author:ChenZhangKun
 * @Date: 2021/5/20 15:41
 */
@RestController
@RequestMapping("/side")
public class SideCarController {
    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/car")
    public String sideCar() {
        // 直接通过sidecar服务名访问
        String url = "http://sideCar/side/car";
        return restTemplate.getForObject(url, String.class);
    }
}
